package com.system.business;

import com.system.data.api.IUserDataAccess;
import com.system.data.entity.User;
import com.system.entity.Account;

public class AccountController extends BaseAbstractController {
	
	public Account loginWithUsername(final String username){		
		Account account = null;
		final IUserDataAccess userAccess = controllerFactory.getUserDataAccess();
		//
		try {
			final User user = userAccess.getUserWithUsername(username);
			account = convertUserToAccount(user);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return account;
	}
	
	private Account convertUserToAccount(final User user){
		final Account account = new Account();
		account.setUsername(user.getUsername());
		account.setPassword(user.getPassword());
		return account;
	}
}
